package com.gp.library.utils;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.Log;

/**
 * Created by jackdeng on 2021/4/13.
 */

public class ResManager {
    private static Context context;

    public static void init(Context context) {
        ResManager.context = context;
        Log.i("ResManager", "init " + context.getPackageName());
    }

    public static String getString(int resId) {
        return context.getResources().getString(resId);
    }

    public static String getString(int resId, Object args) {
        return context.getResources().getString(resId, args);
    }

    public static Integer getInteger(int resId) {
        return context.getResources().getInteger(resId);
    }

    public static String[] getStringArray(int resId) {
        return context.getResources().getStringArray(resId);
    }

    public static TypedArray getTypedArray(int resId) {
        return context.getResources().obtainTypedArray(resId);
    }

    public static int getColor(int res) {
        return context.getResources().getColor(res);
    }

    public static int[] getIntArray(int resId) {
        return context.getResources().getIntArray(resId);
    }

    static public String getUriOfRawName(String rawName) {
        return "file:///android_res/raw/" + rawName;
    }

    static public String getUriOfAssets(String htmlName) {
        return "file:///android_asset/" + htmlName;
    }

    public static float getDimension(int resId) {
        return context.getResources().getDimension(resId);
    }

    public static int getDimensionPixelSize(int resId) {
        return context.getResources().getDimensionPixelSize(resId);
    }

    public static Drawable getDrawable(int resId){
        return context.getResources().getDrawable(resId);
    }
}
